﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CodeGenLib;

namespace CodeGen
{
    public partial class ParamCollectionPanel : UserControl, CodeGenLib.View
    {
        private Controller controller;
        private bool inputInclude;

        public ParamCollectionPanel(Controller controller)
        {
            this.inputInclude = true;
            this.controller = controller;
            InitializeComponent();
        }

        public void SetFocus()
        {
            this.classTextBox.Focus();
        }

        public void UpdateCodes(Codes codes)
        {
        }

        public void UpdateInclude(int index, String include)
        {
            this.inputInclude = false;
            switch (index)
            {
                case 0:
                    this.includeTextBox1.Text = include;
                    break;
                case 1:
                    this.includeTextBox2.Text = include;
                    break;
                case 2:
                    this.includeTextBox3.Text = include;
                    break;
            }
            this.inputInclude = true;
        }

        private void classTextBox_TextChanged(object sender, EventArgs e)
        {
            this.controller.UpdateClass(this.classTextBox.Text);
        }

        private void nsTextBox_TextChanged(object sender, EventArgs e)
        {
            this.controller.UpdateNamespace(this.nsTextBox.Text);
        }

        private void baseTextBox1_TextChanged(object sender, EventArgs e)
        {
            this.controller.UpdateBase(0, this.baseTextBox1.Text);
        }

        private void baseTextBox2_TextChanged(object sender, EventArgs e)
        {
            this.controller.UpdateBase(1, this.baseTextBox2.Text);
        }

        private void baseTextBox3_TextChanged(object sender, EventArgs e)
        {
            this.controller.UpdateBase(2, this.baseTextBox3.Text);
        }

        private void includeTextBox1_TextChanged(object sender, EventArgs e)
        {
            if (this.inputInclude)
            {
                this.controller.UpdateInclude(0, this.includeTextBox1.Text);
            }
        }

        private void includeTextBox2_TextChanged(object sender, EventArgs e)
        {
            if (this.inputInclude)
            {
                this.controller.UpdateInclude(1, this.includeTextBox2.Text);
            }
        }

        private void includeTextBox3_TextChanged(object sender, EventArgs e)
        {
            if (this.inputInclude)
            {
                this.controller.UpdateInclude(2, this.includeTextBox3.Text);
            }
        }
    }
}
